package com.lei.chinese_herbal_medicine.Util;

import com.lei.chinese_herbal_medicine.Entity.ViewComponent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MenuUtil {
    private Map map;
    public MenuUtil() {
        map=new HashMap();
        ViewComponent home =new ViewComponent("/home","home","系统模型","s-home","Home.vue");
        ViewComponent chineseHerbalMedicine =new ViewComponent("/chineseHerbalMedicine","chineseHerbalMedicine","数据集管理","user","ChineseHerbalMedicine.vue");
        ViewComponent dataSet =new ViewComponent("/dataSet","dataSet","数据集","user","DataSet.vue");
        ViewComponent optimize =new ViewComponent("/optimize","optimize","系统模型优化","video-play","Optimize.vue");
        ViewComponent versions =new ViewComponent("/versions","versions","模型版本管理","video-play","Versions.vue");
        ViewComponent user =new ViewComponent("/user","user","用户管理", "user","User.vue");
        map.put("home",home);
        map.put("chineseHerbalMedicine",chineseHerbalMedicine);
        map.put("dataSet",dataSet);
        map.put("optimize",optimize);
        map.put("versions",versions);
        map.put("user",user);
        initSuperAdmin();
        initAdmin();
        initUser();
    }

    private List<ViewComponent> superAdmin;
    private List<ViewComponent> admin;
    private List<ViewComponent> user;

    private List<ViewComponent> initSuperAdmin() {
        superAdmin=new ArrayList<>();
        superAdmin.add((ViewComponent) map.get("home"));
        superAdmin.add((ViewComponent) map.get("chineseHerbalMedicine"));
        superAdmin.add((ViewComponent) map.get("dataSet"));
        superAdmin.add((ViewComponent) map.get("optimize"));
        superAdmin.add((ViewComponent) map.get("versions"));
        superAdmin.add((ViewComponent) map.get("user"));
        return superAdmin;
    }

    private List<ViewComponent> initAdmin() {
        admin=new ArrayList<>();
        admin.add((ViewComponent) map.get("home"));
        admin.add((ViewComponent) map.get("user"));
        return admin;
    }

    private List<ViewComponent> initUser() {
        user=new ArrayList<>();
        return user;
    }
    public List<ViewComponent> getMenu(String permission){
        List<ViewComponent> list=null;
        if("超级管理员".equals(permission)){
            list=this.superAdmin;
        }else if ("管理员".equals(permission)){
            list=this.admin;
        }else if("用户".equals(permission)){
            list=this.user;
        }else{//游客 无
        }
        return list;
    }
}
